package com.neusoft.config;

import com.neusoft.interceptor.AdministratorInterceptor;
import com.neusoft.interceptor.GriderInterceptor;
import com.neusoft.interceptor.SupervisorInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JwtInterceptorConfig implements WebMvcConfigurer {
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AdministratorInterceptor(redisTemplate))
                .addPathPatterns("/administrator/*")
                .excludePathPatterns("/Administrator_login");
        registry.addInterceptor(new GriderInterceptor(redisTemplate))
                .addPathPatterns("/grider/*")
                .excludePathPatterns("/grider_login");
        registry.addInterceptor(new SupervisorInterceptor(redisTemplate))
                .addPathPatterns("/supervisor/*")
                .excludePathPatterns("/supervisor_login","/supervisor/register");
    }
}
